# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: eolianoe <eolianoe At GoogleMAIL DoT com>

_name=click-log
pkgname=python-click-log
pkgver=0.4.0
pkgrel=3
pkgdesc="Logging integration for Click"
arch=('any')
url="https://github.com/click-contrib/click-log"
license=('MIT')
depends=('python-click')
makedepends=('python-build' 'python-installer' 'python-setuptools'
             'python-wheel')
checkdepends=('python-pytest')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz")
sha256sums=('3970f8570ac54491237bcdb3d8ab5e3eef6c057df29f8c3d1151a51a9c23b975')
b2sums=('8a7ce0c2a7617253f08d011958bce158e987faa0008065c9dac382d46b905cc88cd5cb19d0d0859bf522da6448f7c9a20c0a8efe53b3feb5efc9ca3f64cfbc27')

build() {
  cd $_name-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd $_name-$pkgver
  export PYTHONPATH="build:$PYTHONPATH"
  pytest -v
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/click_log-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
